---
order: 2
title: Export To WechatMiniGame
type: Platform
label: Platform
---

## Platform Configuration Instructions

When exporting to the WeChat Mini Game platform, there are the following configuration items:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*Dc_mQITPRogAAAAAAAAAAAAAejCHAQ/fmt.webp" />

| Configuration          | Describe                                                                                                                              | Corresponding to the configuration file of WeChat Mini Games | Corresponding to the fields in WeChat Mini Games
| ------------- | ------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| AppId | AppId of WeChat Mini Game, required. The wxdf8199565c509fb9 in the screenshot is a test account. | project.config.json | appid |
| Orientation | Set the game screen orientation: Landscape, Portrait| game.json | deviceOrientation |
| Request | wx.request timeout, unit: milliseconds | game.json | networkTimeout.request |
| Connect Socket | wx.connectSocket timeout, unit: milliseconds | game.json | networkTimeout.connectSocket |
| Upload File | wx.uploadFile timeout, unit: milliseconds | game.json | networkTimeout.uploadFile |
| Download File | wx.downloadFile timeout, unit: milliseconds | game.json | networkTimeout.downloadFile |
| Subpackages | Subpackage list configuration | game.json | subpackages |

For more configuration details, see: [project.config.json](https://developers.weixin.qq.com/minigame/dev/devtools/projectconfig.html)、[game.json](https://developers.weixin.qq.com/minigame/dev/reference/configuration/app.html)

## Export

After selecting the WeChat Mini Game platform, click the download button at the bottom of the export panel to export the required project:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*yAeER487lbsAAAAAAAAAAAAAejCHAQ/fmt.webp" />

## Debug

1. After exporting from the editor to the local directory, the directory structure is as follows:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*LMWMQpQNdA0AAAAAAAAAAAAAejCHAQ/fmt.webp" style={{zoom: "50%"}} />

**Project Directory Description**
| Directory or File | Description |
|-------------------|-------------|
| public            | Asset directory. All assets from the editor are exported to this directory, and the asset path is /public/xxx |
| scripts           | Scripts added by developers in the editor. After exporting locally, developers can further develop these script components |
| game.json         | Corresponds to the [game.json](https://developers.weixin.qq.com/minigame/dev/reference/configuration/app.html) required for the WeChat Mini Game project |
| game.ts           | Entry file where all initialization logic is placed |
| package.json      | Mainly stores project dependencies |
| project.config.json | Corresponds to the [project.config.json](https://developers.weixin.qq.com/minigame/dev/devtools/projectconfig.html) required for the WeChat Mini Game project |
| project.ts        | Galacean project file, containing initialization-related information |

2. After exporting the project locally, navigate to the root directory and run the following command to install dependencies:

```bash
npm i
```

3. To locally build the output required for the WeChat Mini Game platform during the debugging phase, run the following command:

```bash
npm run dev
```
After running this command, a new directory will be generated in the root directory of the project. This directory contains the output required for the WeChat Mini Game, as shown below:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*wYi0QoS-BUsAAAAAAAAAAAAAejCHAQ/fmt.webp" style={{zoom: "50%"}} />

When running the `dev` command, the output will include source map files for debugging. Once the developer has completed debugging and is ready to release, the following command can be executed:

```bash
npm run release
```

After running this command, the output compared to `dev` will remove the source map files and compress the code, making it smaller and suitable for release, as shown below:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*7mvZR6wwEV4AAAAAAAAAAAAAejCHAQ/fmt.webp" style={{zoom: "50%"}} />

4. Open **WeChat Developer Tools**, select Mini Game, and import the directory generated in step 3, as shown below:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*v-odQJDjcfUAAAAAAAAAAAAAejCHAQ/fmt.webp" />

5. After completing step 4, you can preview the final result in the WeChat Developer Tools, as shown below:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*meRxSLDswlgAAAAAAAAAAAAAejCHAQ/fmt.webp" />

6. For debugging in the WeChat Developer Tools, see: [WeChat Mini Game Debugging](https://developers.weixin.qq.com/minigame/dev/guide/runtime/debug/)

## Subpackage

### Overview

As mini-games become increasingly complex with more content, the package size grows, affecting loading speed. WeChat Mini Games provide a subpackage feature that splits the game content into a main package and subpackages according to rules. The main package contains resources necessary for the initial launch, while subpackages are loaded as needed, allowing users to quickly enter the game.

### Subpackage Configuration in Galacean Editor

In the Galacean editor, folders are the unit for subpackage division. Content not in subpackages will go into the main package. When exporting the mini-game, add subpackages in the subpackage list of the export panel and associate them with folders to complete the subpackage configuration.

### Subpackage Configuration Steps

1. Open the export panel, select the WeChat Mini Game platform, and click the "Add Subpackage" button in the subpackage list to add a subpackage:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*j5u6Q7txvj4AAAAAAAAAAAAAejCHAQ/fmt.webp" />

2. In the subpackage, select the folder to be included in the subpackage to complete the configuration:

<Image src="https://mdn.alipayobjects.com/huamei_w6ifet/afts/img/A*ndgyR5bjGqsAAAAAAAAAAAAAejCHAQ/fmt.webp" />

### Notes

- Script resources in folders set as subpackages will not be included in the subpackage but will be exported to the main package separately.
- In WeChat Mini Games, the main package size is limited to 4MB. There is no size limit for a single subpackage, but the total size of the main package and subpackages cannot exceed 30MB. For more detailed rules, see: [Subpackage](https://developers.weixin.qq.com/minigame/dev/guide/base-ability/subPackage/useSubPackage.html)
- The configuration, loading, and other processes of subpackages are automatically handled by the engine. Developers can dynamically load assets in subpackages and regular assets in the same way using `engine.resourceManager.load`.

## Release

After completing local debugging, you can proceed with the release. For detailed release steps, see: [WeChat Mini Game Release](https://developers.weixin.qq.com/minigame/introduction/guide/)